package com.randi.monitor.controller;

import com.randi.common.core.domain.Result;
import com.randi.monitor.dto.SysUserOnline;
import com.randi.monitor.service.ISysUserOnlineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ziye
 */
@RestController
@RequestMapping("monitor/online")
@Api(tags = "在线用户")
public class SysOnlineController {

    @Resource
    private ISysUserOnlineService iSysUserOnlineService;

    /**
     * 获取列表
     *
     * @param sysUserOnline sysUserOnline
     * @return Result
     */
    @PostMapping("/list")
    @ApiOperation(value = "在线用户列表", notes = "")
    public Result onlineUserList(@RequestBody SysUserOnline sysUserOnline) {
        List<SysUserOnline> onlineList = iSysUserOnlineService.selectOnlineUserList(sysUserOnline);
        return Result.success().put(onlineList);
    }

    /**
     * 强制退出
     *
     * @param tokenId tokenId
     * @return Result
     */
    @PostMapping("/force")
    @ApiOperation(value = "强制退出", notes = "")
    public Result onlineUserForceLogout(@RequestBody String tokenId) {
        iSysUserOnlineService.onlineUserForceLogout(tokenId);
        return Result.success();
    }

}
